﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using SmartSiteManagementSystem.IServices;
using SmartSiteManagementSystem.IRepository.ProjectManage;
using SmartSiteManagementSystem.Models.ProjectManage;
using System.Linq;

namespace SmartSiteManagementSystem.Services
{
    public class ProjectManageService :IProjectManageService
    {

        private readonly IProjectInfoRepository _projectInfoRepository;

        private readonly IDayProjectTypeInfoRepository _dayProjectTypeInfoRepository;


        private readonly IDayProjectInfoRepository _dayProjectInfoRepository;

        public ProjectManageService(IProjectInfoRepository projectInfoRepository,
            IDayProjectTypeInfoRepository dayProjectTypeInfoRepository
            , IDayProjectInfoRepository dayProjectInfoRepository)
        {
            _projectInfoRepository = projectInfoRepository;
            _dayProjectTypeInfoRepository = dayProjectTypeInfoRepository;
            _dayProjectInfoRepository = dayProjectInfoRepository;
        }

        #region ProjectInfo
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public int GetProjectInfoListCount(Hashtable param)
        {
            return _projectInfoRepository.GetCount(param);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <param name="orderBy"></param>
        /// <param name="first"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        public IList<ProjectInfo> GetProjectInfoList(Hashtable param,string orderBy,int first,int rows)
        {
            return _projectInfoRepository.GetList(param, orderBy, first, rows);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public ProjectInfo GetProjectInfoById(int projectId)
        {
            Hashtable param = new Hashtable();
            param.Add("project_id", projectId);
            return _projectInfoRepository.Get(param);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="projectInfo"></param>
        /// <returns></returns>
        public bool UpdateProjectInfo(ProjectInfo projectInfo)
        {
            bool back = _projectInfoRepository.Update(projectInfo);
            return back;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="projectInfo"></param>
        /// <returns></returns>
        public int InsertProjectInfo(ProjectInfo projectInfo)
        {
            return _projectInfoRepository.Insert(projectInfo);
        }
        #endregion

        #region DayProjectTypeInfo
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dayProjectTypeId"></param>
        /// <returns></returns>
        public DayProjectTypeInfo GetDayProjectTypeInfoById(int dayProjectTypeId)
        {
            Hashtable param = new Hashtable();
            param.Add("day_project_type_id", dayProjectTypeId);
            return _dayProjectTypeInfoRepository.Get(param);
            
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dayProjectTypeInfo"></param>
        /// <returns></returns>
        public bool UpdateDayProjectTypeInfo(DayProjectTypeInfo dayProjectTypeInfo)
        {
            bool back = _dayProjectTypeInfoRepository.Update(dayProjectTypeInfo);
            return back;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dayProjectTypeInfo"></param>
        /// <returns></returns>
        public int InsertDayProjectTypeInfo(DayProjectTypeInfo dayProjectTypeInfo)
        {
            return _dayProjectTypeInfoRepository.Insert(dayProjectTypeInfo);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public int GetDayProjectTypeInfoListCount(Hashtable param)
        {
            return _dayProjectTypeInfoRepository.GetCount(param);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <param name="orderBy"></param>
        /// <param name="first"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        public IList<DayProjectTypeInfo> GetDayProjectTypeInfoList(Hashtable param, string orderBy, int first, int rows)
        {
            return _dayProjectTypeInfoRepository.GetList(param, orderBy, first, rows);
        }
        #endregion

        #region DayProjectInfo
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dayProjectId"></param>
        /// <returns></returns>
        public DayProjectInfo GetDayProjectInfoById(int dayProjectId)
        {
            Hashtable param = new Hashtable();
            param.Add("day_project_id", dayProjectId);
            return _dayProjectInfoRepository.Get(param);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dayProjectInfo"></param>
        /// <returns></returns>
        public bool UpdateDayProjectInfo(DayProjectInfo dayProjectInfo)
        {
            bool back = _dayProjectInfoRepository.Update(dayProjectInfo);
            return back;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dayProjectInfo"></param>
        /// <returns></returns>
        public int InsertDayProjectInfo(DayProjectInfo dayProjectInfo)
        {
            return _dayProjectInfoRepository.Insert(dayProjectInfo);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public int GetDayProjectInfoListCount(Hashtable param)
        {
            return _dayProjectInfoRepository.GetCount(param);
        }

        public IList<DayProjectInfo> GetDayProjectInfoList(Hashtable param, string orderBy, int first, int rows)
        {
            return _dayProjectInfoRepository.GetList(param, orderBy, first, rows);
        }


        /// <summary>
        /// 获取任务状态 0  任务未下发 5 任务已分配 10 任务已下发 15 任务已完成
        /// </summary>
        /// <param name="statusType"></param>
        /// <returns></returns>
        public string GetStatusTypeStr(int statusType)
        {
            string back = "";
            if (statusType == 0)
            {
                back = "新任务";
            }
            else if (statusType == 5)
            {
                back = "任务已分配";
            }
            else if (statusType == 10)
            {
                back = "任务已下发";
            }
            else if (statusType == 15)
            {
                back = "任务已完成";
            }
            return back;
        }
        #endregion

    }
}
